home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magazyn Exec 5
/
CD_Magazyn_EXEC_nr_5.iso
/
eXec
/
Pokazac obrazek
/
datatype2.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-08-31
|
3KB
|
111 lines
/* Îadowanie i wyôwietlanie obrazka przez datatypes.library - przykîad 2 */
/* Grzegorz "Krashan" Kraszewski, eXec */
#define __NOLIBBASE__
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/datatypes.h>
#include <proto/graphics.h>
#include <datatypes/pictureclass.h>
struct Library *SysBase, *IntuitionBase, *DataTypesBase, *GfxBase;
BOOL OpenLibs (void)
{
if (!(IntuitionBase = OpenLibrary ("intuition.library", 39))) return FALSE;
if (!(DataTypesBase = OpenLibrary ("datatypes.library", 39))) return FALSE;
if (!(GfxBase = OpenLibrary ("graphics.library", 39))) return FALSE;
return TRUE;
}
void CloseLibs (void)
{
if (DataTypesBase) CloseLibrary (DataTypesBase);
if (IntuitionBase) CloseLibrary (IntuitionBase);
if (GfxBase) CloseLibrary (GfxBase);
return;
}
int main (void)
{
BOOL ok = TRUE;
Object *picture;
LONG width, height;
struct Window *okno;
if (ok = OpenLibs ())
{
if (picture = NewDTObject ("PROGDIR:obrazek", DTA_GroupID, GID_PICTURE,
PDTA_Remap, TRUE, TAG_END))
{
GetDTAttrs (picture,
DTA_NominalHoriz, (LONG)&width,
DTA_NominalVert, (LONG)&height,
TAG_END);
if (okno = OpenWindowTags (NULL,
WA_InnerWidth, width,
WA_InnerHeight, height,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_Activate, TRUE,
WA_SmartRefresh, TRUE,
WA_IDCMP, IDCMP_CLOSEWINDOW,
WA_Title, (LONG)"Przykîad 2",
TAG_END))
{
struct IntuiMessage *msg;
struct BitMap *bm;
LONG msgclass;
BOOL run = TRUE;
/* Poniûsza linia to jedyna róûnica w stosunku do wersji 1 */
SetDTAttrs (picture, NULL, NULL, PDTA_Screen, (LONG)okno->WScreen,
TAG_END);
/* ------------------------------------------------------- */
DoDTMethod (picture, NULL, NULL, DTM_PROCLAYOUT, NULL, DTSIF_NEWSIZE);
GetDTAttrs (picture, PDTA_DestBitMap, (LONG)&bm, TAG_END);
if (bm) BltBitMapRastPort (bm, 0, 0, okno->RPort, okno->BorderLeft,
okno->BorderTop, width, height, 0xC0);
while (run)
{
WaitPort (okno->UserPort);
while (msg = (struct IntuiMessage*)GetMsg (okno->UserPort))
{
msgclass = msg->Class;
ReplyMsg ((struct Message*)msg);
if (msgclass == IDCMP_CLOSEWINDOW) run = FALSE;
}
}
CloseWindow (okno);
}
DisposeDTObject (picture);
}
else ok = FALSE;
}
CloseLibs ();
if (ok) return 0;
else
{
printf ("bîâd\n");
return 10;
}
}